@import 'variables';

.van-button {
  position: relative;
  display: inline-block;
  box-sizing: border-box;
  width: $button-default-height;
  margin: 0;
  padding: 0;
  font-size: $button-default-font-size;
  line-height: $button-default-line-height;
  text-align: center;
  border-radius: $button-border-radius;
  -webkit-appearance: none;
  -webkit-text-size-adjust: 100%;
  //
  // &:not(:first-child) {
  //   margin-top: 1.5rem;
  // }

  &::before {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background-color: $black;
    border: inherit;
    border-color: $black;
    border-radius: inherit; /* inherit parent's border radius */
    transform: translate(-50%, -50%);
    opacity: 0;
    content: ' ';
  }

  &:active::before {
    opacity: .1;
  }

  &--loading,
  &--disabled {
    &::before {
      display: none;
    }
  }

  &--default {
    color: $button-default-color;
    background-color: $button-default-background-color;
    border: $button-border-width solid $button-default-border-color;
  }

  &--primary {
    color: $button-primary-color;
    background-color: $button-primary-background-color;
    border: $button-border-width solid $button-primary-border-color;
  }

  &--info {
    color: $button-info-color;
    background-color: $button-info-background-color;
    border: $button-border-width solid $button-info-border-color;
  }

  &--danger {
    color: $button-danger-color;
    background-color: $button-danger-background-color;
    border: $button-border-width solid $button-danger-border-color;
  }

  &--warning {
    color: $button-warning-color;
    background-color: $button-warning-background-color;
    border: $button-border-width solid $button-warning-border-color;
  }

  &--plain {
    background-color: $button-plain-background-color;

    &.van-button--primary {
      color: $button-primary-background-color;
    }

    &.van-button--info {
      color: $button-info-background-color;
    }

    &.van-button--danger {
      color: $button-danger-background-color;
    }

    &.van-button--warning {
      color: $button-warning-background-color;
    }
  }

  &--large {
    height: 100%;
    width: $button-large-height;
    line-height: $button-large-line-height;
  }

  &--normal {
    padding: 15px 0;
    font-size: $button-normal-font-size;
  }

  &--small {
    min-height: $button-small-min-width;
    width: $button-small-height;
    padding: $padding-xs 0;
    font-size: $button-small-font-size;
    line-height: $button-small-line-height;
  }

  &__loading {
    display: inline-block;
    vertical-align: top;
  }

  &--mini {
    display: inline-block;
    min-height: $button-mini-min-width;
    width: $button-mini-height;
    font-size: $button-mini-font-size;
    line-height: $button-mini-line-height;

    & + .van-button--mini {
      margin-left: 5px;
    }
  }

  &--block {
    display: block;
    width: 100%;
  }

  &--disabled {
    opacity: $button-disabled-opacity;
  }

  &--round {
    border-radius: $button-round-border-radius;
  }

  &--square {
    border-radius: 0;
  }

  &__icon {
    min-width: 1em;
    font-size: 1.2em;
    line-height: inherit;
    vertical-align: top;
  }

  &__icon + &__text,
  &__loading + &__text {
    display: inline-block;
    margin-left: 5px;
    vertical-align: top;
  }

  &--hairline {
    border-width: 0;

    &::after {
      border-color: inherit;
      border-radius: $button-border-radius * 2;
    }

    &.van-button--round::after {
      border-radius: $button-round-border-radius;
    }

    &.van-button--square::after {
      border-radius: 0;
    }
  }
}
